<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <title></title>
        <#include "/inc/head.ftl"/>
    	<@head/> 
</head>
<body>
            <div class="panel panel-default">
                <div class="panel-body">
                    <div class="row">
						<div class="col-lg-12">
                            <form id="form" action = "${contextPath}/things/authorize" thingslei="form" method="post">
                                <input  id="id" name= "id" type="hidden" value="${(things.id)!}" class="form-control">
                                <div class="form-group">
                                    <label>商品名</label>
                                    <input id="name"   name="name" value="${(things.name)!}" class="form-control" disabled="disabled" >
                                </div>
              
                                <div class="form-group">
                                    <label>所属类别</label>
                                    <select id="thingslei"  name="thingsleiId"  class="form-control">
                                    </select>
                                </div>
                                <div align="right">
                                <button id="btn-submit"  type="submit"  class="btn btn-default">提交</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <!-- /.panel-body -->
       </div>
       <!-- /.panel -->
       <script>
       $(function() {
           $('form').validate({
               submitHandler : function(form) {
		               $(form).ajaxSubmit(function(data) {
		                   if(data.result){
		                	   parent.layer.msg(data.msg, {time: 1000, icon:1});			                	   
		                   }else{
		                	   parent.layer.msg(data.msg, {time: 1000, icon:2});	
		                   }  
		                   var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
    		        	   parent.layer.close(index); 
		               });
               } 
           });
           initSelector();
       });
       
       function initSelector(){
   	    var selector=  $("#thingslei");
   		 selector.append("<option value='-1'>选择商品类别</option>"); 
   		 <#list thingslei as r>  //freemarker遍历用法
   		 var leiName="${r.leiName}";
   		 var id = "${r.id}";
   		 selector.append("<option value='"+id+"'>"+leiName+"</option>");
   		 </#list>
   		selector.val(${(things.thingsleiId)!}); //用户当前的权限值被选中
      }
    </script>
    </body>
</html>    	 
    	 